{extend name="main"}

{block name='content'}
<form action="{:sysuri()}" method="post" data-auto="true" class="layui-form layui-card">
    <div class="layui-card-body">

        <fieldset class="layui-form-item border-0 shadow-inset">
            <legend><span class="layui-badge think-bg-violet">结算周期</span></legend>
            <div class="layui-form-item">
                {php} $data['teams_type'] = $data['teams_type'] ?? 1; {/php}
                {foreach [1 => '实时结算'] as $key => $val}{if $data.teams_type eq $key}
                <input class="layui-input" name="teams_type" title="{$val}" type="radio" value="{$key}" checked>
                {else}
                <input class="layui-input" name="teams_type" title="{$val}" type="radio" value="{$key}">
                {/if}{/foreach}
            </div>
        </fieldset>

        <fieldset class="layui-form-item border-0 shadow-inset">
            <legend><span class="layui-badge think-bg-violet">到账事件</span></legend>
            <div class="layui-form-item">
                {php} $data['settl_type'] = $data['settl_type'] ?? 1; {/php}
                {foreach [1 => '支付后立即到账', 2 => '确认收货后到账'] as $key => $val}{if $data.settl_type eq $key}
                <input class="layui-input" name="settl_type" title="{$val}" type="radio" value="{$key}" checked>
                {else}
                <input class="layui-input" name="settl_type" title="{$val}" type="radio" value="{$key}">
                {/if}{/foreach}
            </div>
        </fieldset>

        <div class="layui-tab layui-tab-card shadow-none">
            <ul class="layui-tab-title">
                {foreach $levels as $one}
                <li data-rule-tab>[ <b class="color-red">VIP{$one.number|default=0}</b> ] {$one.name|default=''}</li>
                {/foreach}
            </ul>
            <div class="layui-tab-content">
                {foreach $levels as $one}
                <div class="layui-tab-item">
                    {foreach $levels as $two}
                    <fieldset>
                        <legend>
                            <span class="layui-badge think-bg-violet">{$one.name}</span><i class="layui-icon font-s10">&#xe602;</i>
                            <span class="layui-badge think-bg-violet">{$two.name}</span>
                        </legend>
                        <div class="layu-row layui-col-space20">
                            <div class="layui-col-md12 layui-col-lg6">
                                <fieldset class="shadow-inset border-0 margin-0">
                                    <legend><span class="layui-badge layui-bg-blue">首推奖励</span></legend>
                                    <div class="layui-form-item">
                                        {php} $key = 'frist_type_vip_'.$one['number'].'_'.$two['number']; {/php}
                                        {php} $data[$key] = $data[$key] ?? 0; {/php}
                                        {foreach ['关闭奖励', '固定金额 / 每单', '金额比例 / 每单'] as $k => $v}
                                        {if isset($data[$key]) and $data[$key] eq $k}
                                        <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}" checked>
                                        {else}
                                        <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}">
                                        {/if}{/foreach}
                                        <label class="block relative">
                                            {php} $key = 'frist_value_vip_'.$one['number'].'_'.$two['number']; {/php}
                                            <span class="color-blue"><b>请输入奖励金额或返利金额比例，</b>如：比例填写 10.00 表示 10.00% 或 10.00 元</span>
                                            <input type="number" step="0.0001" min="0.0000" class="layui-input" data-blur-number="4" name="{$key}" placeholder="请输入奖励金额或返利金额比例" value="{$data[$key]??'0.0000'}">
                                        </label>
                                    </div>
                                </fieldset>
                            </div>
                            <div class="layui-col-md12 layui-col-lg6">
                                <fieldset class="shadow-inset border-0 margin-0">
                                    <legend><span class="layui-badge layui-bg-blue">复购奖励</span></legend>
                                    <div class="layui-form-item">
                                        {php} $key = 'repeat_type_vip_'.$one['number'].'_'.$two['number']; {/php}
                                        {php} $data[$key] = $data[$key] ?? 0; {/php}
                                        {foreach ['关闭奖励', '固定金额 / 每单', '金额比例 / 每单'] as $k => $v}
                                        {if isset($data[$key]) and $data[$key] eq $k}
                                        <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}" checked>
                                        {else}
                                        <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}">
                                        {/if}{/foreach}
                                        <label class="block relative">
                                            {php} $key = 'repeat_value_vip_'.$one['number'].'_'.$two['number']; {/php}
                                            <span class="color-blue"><b>请输入奖励金额或返利金额比例</b>，如：比例填写 10.00 表示 10.00% 或 10.00 元</span>
                                            <input type="number" step="0.0001" min="0.0000" class="layui-input" data-blur-number="4" name="{$key}" placeholder="请输入奖励金额或返利金额比例" value="{$data[$key]??'0.0000'}">
                                        </label>
                                    </div>
                                </fieldset>
                            </div>
                        </div>
                    </fieldset>
                    {/foreach}

                    <div class="layui-row layui-col-space20">
                        <div class="layui-col-xs6">
                            <fieldset class="shadow-inset border-0 margin-0">
                                <legend><span class="layui-badge layui-bg-blue">直属团队奖励</span></legend>
                                <div class="layui-form-item">
                                    {php} $key = 'direct_type_vip_'.$one['number']; {/php}
                                    {php} $data[$key] = $data[$key] ?? 0; {/php}
                                    {foreach ['关闭奖励', '固定金额 / 每单', '金额比例 / 每单'] as $k => $v}
                                    {if isset($data[$key]) and $data[$key] eq $k}
                                    <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}" checked>
                                    {else}
                                    <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}">
                                    {/if}{/foreach}
                                    <label class="block">
                                        {php} $key = 'direct_value_vip_'.$one['number']; {/php}
                                        <span class="color-blue"><b>请输入奖励金额或返利金额比例</b>（ 如：比例填写 10.00 表示 10.00% 或 10.00 元 ）</span>
                                        <input type="number" step="0.0001" min="0.0000" class="layui-input" data-blur-number="4" name="{$key}" placeholder="请输入奖励金额或返利金额比例" value="{$data[$key]??'0.0000'}">
                                    </label>
                                </div>
                            </fieldset>
                        </div>
                        <div class="layui-col-xs6">
                            <fieldset class="shadow-inset border-0 margin-0">
                                <legend><span class="layui-badge layui-bg-blue">间接团队奖励</span></legend>
                                <div class="layui-form-item">
                                    {php} $key = 'indirect_type_vip_'.$one['number']; {/php}
                                    {php} $data[$key] = $data[$key] ?? 0; {/php}
                                    {foreach ['关闭奖励', '固定金额 / 每单', '金额比例 / 每单'] as $k => $v}
                                    {if isset($data[$key]) and $data[$key] eq $k}
                                    <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}" checked>
                                    {else}
                                    <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}">
                                    {/if}{/foreach}
                                    <label class="block">
                                        {php} $key = 'indirect_value_vip_'.$one['number']; {/php}
                                        <span class="color-blue"><b>请输入奖励金额或返利金额比例</b>（ 如：比例填写 10.00 表示 10.00% 或 10.00 元 ）</span>
                                        <input type="number" step="0.0001" min="0.0000" class="layui-input" data-blur-number="4" name="{$key}" placeholder="请输入奖励金额或返利金额比例" value="{$data[$key]??'0.0000'}">
                                    </label>
                                </div>
                            </fieldset>
                        </div>
                    </div>
                    <div class="layui-row layui-col-space20">
                        <div class="layui-col-xs6">
                            <fieldset class="shadow-inset border-0 margin-0">
                                <legend><span class="layui-badge layui-bg-blue">升级 {$one.name} 奖励</span></legend>
                                <div class="layui-form-item">
                                    {php} $key = 'upgrade_type_vip_'.$one['number'].'_'.$two['number']; {/php}
                                    {php} $data[$key] = $data[$key] ?? 0; {/php}
                                    {foreach ['关闭奖励', '固定金额 / 每单', '金额比例 / 每单'] as $k => $v}
                                    {if isset($data[$key]) and $data[$key] eq $k}
                                    <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}" checked>
                                    {else}
                                    <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}">
                                    {/if}{/foreach}
                                    <label class="block">
                                        {php} $key = 'upgrade_value_vip_'.$one['number']; {/php}
                                        <span class="color-blue"><b>请输入固定奖励金额</b>（ 如：比例填写 10.00 表示 10.00 元或 10.00% ）<b class="color-red">仅针对订单升级有效！</b></span>
                                        <input type="number" step="0.0001" min="0.0000" class="layui-input" data-blur-number="4" name="{$key}" placeholder="请输入奖励金额或返利金额比例" value="{$data[$key]??'0.0000'}">
                                    </label>
                                </div>
                            </fieldset>
                        </div>
                        <div class="layui-col-xs6">
                            <fieldset class="shadow-inset border-0 margin-0">
                                <legend><span class="layui-badge layui-bg-blue">平推 {$one.name} 奖励</span></legend>
                                <div class="layui-form-item">
                                    <div class="layui-row layui-col-space20">
                                        <label class="layui-col-xs12 layui-col-sm12 layui-col-md6">
                                            {php} $key = 'equal_value_vip_1_'.$one['number']; {/php}
                                            <span><b class="color-blue">请输入直属上级奖励金额</b><br><span class="color-desc">如：比例填写 10.00 表示 10.00 元</span></span>
                                            <input type="number" step="0.01" min="0.0000" class="layui-input" data-blur-number="2" name="{$key}" placeholder="请输入奖励金额" value="{$data[$key]??'0.00'}">
                                        </label>
                                        <label class="layui-col-xs12 layui-col-sm12 layui-col-md6">
                                            {php} $key = 'equal_value_vip_2_'.$one['number']; {/php}
                                            <span><b class="color-blue">请输入上上级奖励金额</b><br><span class="color-desc">如：比例填写 10.00 表示 10.00 元</span></span>
                                            <input type="number" step="0.01" min="0.0000" class="layui-input" data-blur-number="2" name="{$key}" placeholder="请输入奖励金额" value="{$data[$key]??'0.00'}">
                                        </label>
                                    </div>
                                </div>
                            </fieldset>
                        </div>
                        <div class="layui-col-xs6">
                            <fieldset class="shadow-inset border-0 margin-0">
                                <legend><span class="layui-badge layui-bg-blue">管理 {$one.name} 奖励</span></legend>
                                <div class="layui-form-item">
                                    {php} $key = 'manage_type_vip_'.$one['number']; {/php}
                                    {php} $data[$key] = $data[$key] ?? 0; {/php}
                                    {foreach ['关闭奖金', '不累计未发管理奖金额', '累计未发放管理奖金'] as $k => $v}
                                    {if isset($data[$key]) and $data[$key] eq $k}
                                    <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}" checked>
                                    {else}
                                    <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}">
                                    {/if}{/foreach}
                                    <label class="block">
                                        {php} $key = 'manage_value_vip_'.$one['number']; {/php}
                                        <span class="color-blue"><b>请输入固定奖励金额</b>（ 如：比例填写 10.00 表示 10.00 元 ）</span>
                                        <input type="number" step="0.0001" min="0.0000" class="layui-input" data-blur-number="4" name="{$key}" placeholder="请输入奖励金额或返利金额比例" value="{$data[$key]??'0.0000'}">
                                    </label>
                                </div>
                            </fieldset>
                        </div>
                    </div>
                </div>
                {/foreach}
            </div>
        </div>

        <div class="layui-form-item text-center margin-top-30">
            <button class="layui-btn" type='submit'>保存配置</button>
            <button class="layui-btn layui-btn-danger" data-confirm="确定要取消编辑吗？" data-history-back type='button'>取消编辑</button>
        </div>

    </div>
</form>

<script>
    $(function () {
        $('li[data-rule-tab]:first-child').trigger('click');
    });
</script>

{/block}